
function Scene(engine)
{
  this.engine = engine;
  this.timer = null;
}

// MEMBERS TO BE OVERRIDDEN

Scene.prototype.build = function (engine)
{
  
}

Scene.prototype.destroy = function (engine)
{
  
}

Scene.prototype.main = function (engine)
{
  
}

// Core Masking Functions

Scene.prototype.start = function ()
{
  this.build(this.engine);
  this.engine.loadAssets(bind(this,this.assetsLoaded));
}

Scene.prototype.stop = function ()
{
  this.destroy(this.engine);
}

Scene.prototype.assetsLoaded = function ()
{
  this.timer = new Date().getTime()
  this.main(this.engine);
}

// Generic Helper Functions

Scene.prototype.getTimeChange = function ()
{
    var newTime = new Date().getTime();
    var elapsed = newTime - this.timer;
    this.timer = newTime;
    
    return elapsed; 
}


function SceneButton(engine,name,clickCallback)
{
  this.engine = engine;
  this.name = name;
  
  this.mouseOver = false;
  
  this.engine.addGizmo(new Gizmo(name,clickCallback,bind(this,this.over),bind(this,this.enter),bind(this,this.leave)));   
}

SceneButton.prototype.enter = function (type,name,point)
{
  this.mouseOver = true;
}

SceneButton.prototype.leave = function (type,name,point)
{
  this.mouseOver = false;
}

SceneButton.prototype.over = function (type,name,point)
{
  this.mouseOver = true;
}

SceneButton.prototype.drawOn = function ()
{
  
}


SceneButton.prototype.drawOff = function ()
{
  
}


SceneButton.prototype.draw = function ()
{
  this.engine.startGizmo(this.name);
  
  if(this.mouseOver)
    this.drawOn();
  else
    this.drawOff();
    
  this.engine.stopGizmo();
}


function SceneImageButton(engine,name,clickCallback,mouseOnSrc,mouseOffSrc,point1,point2)
{
  SceneButton.call(this,engine,name,clickCallback);
  
  engine.addImage('button_'+this.name+'_mouseOn',mouseOnSrc);
  engine.addImage('button_'+this.name+'_mouseOff',mouseOffSrc);
  
  this.point1 = point1;
  this.point2 = point2;
}

SceneImageButton.inherit(SceneButton);

SceneImageButton.prototype.drawOn = function ()
{
  this.engine.drawImage(this.engine.layers.length - 1,'button_'+this.name+'_mouseOn',this.point1,this.point2);
}

SceneImageButton.prototype.drawOff = function ()
{
  this.engine.drawImage(this.engine.layers.length - 1,'button_'+this.name+'_mouseOff',this.point1,this.point2);
}
